<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "forecast".
 *
 * @property int $id
 * @property int|null $regionId
 * @property string|null $dateTime
 * @property float|null $temperature
 * @property string|null $weatherCondition
 *
 * @property Region $region
 */
class Forecast extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'forecast';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['regionId'], 'default', 'value' => null],
            [['regionId'], 'integer'],
            [['dateTime'], 'safe'],
            [['temperature'], 'number'],
            [['weatherCondition'], 'string', 'max' => 255],
            [['regionId'], 'exist', 'skipOnError' => true, 'targetClass' => Region::class, 'targetAttribute' => ['regionId' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'regionId' => 'Region ID',
            'dateTime' => 'Date Time',
            'temperature' => 'Temperature',
            'weatherCondition' => 'Weather Condition',
        ];
    }

    /**
     * Gets query for [[Region]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getRegion()
    {
        return $this->hasOne(Region::class, ['id' => 'regionId']);
    }
}
